let id = location.href.split('?')[1]


$(
()=>{

    if (id) {

        $.get('http://localhost:3000/product',data=>{
   

            let newData =data.filter(item=>{

                return item.id==id

            })



            $('#Title').val(newData[0].Title)
            $('#Digest').val(newData[0].Digest  )
            $('#Content').val(newData[0].Content )
            $('#Classify').val(newData[0].Classify  )
            $('#Author').val(newData[0].Author )


   
    })


    }

}


)


function save(){

let obj = {

    Title: $('#Title').val(),
    Digest :$('#Digest').val(),
    Content: $('#Content').val(),
    Classify: $('#Classify').val(),
    Author: $('#Author').val()

}

let type ="post"    


if (id) {

    obj.id=id

    type="put"

}

Data(type,obj)


}














